package com.msh.artascope.devcloud.client.po;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.msh.artascope.interfaces.ILoginAccount;
import com.msh.frame.client.base.BasePo;
import com.msh.frame.client.validation.IInsertVo;
import com.msh.frame.client.validation.IUpdateVo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Date;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * @author shihu
 * @mail m-sh@qq.com
 */
@Data
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Schema(name = "构建记录Po")
public class ModuleBuildPo extends BasePo{
  @NotNull(groups = {IUpdateVo.class}, message = "id不能为空")
  @Schema(name = "主键")
  private Long id;

  @Schema(name = "项目Id")
  private Long projectId;

  @NotNull(groups = {IInsertVo.class},message = "模块Id不能为空")
  @Schema(name = "模块Id")
  private Long moduleId;

  @NotNull(groups = {IInsertVo.class},message = "分支不能为空")
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 50, message = "branch长度范围最大50")
  @Schema(name = "分支")
  private String branch;

  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 100, message = "pipelineName长度范围最大100")
  @Schema(name = "pipeline名称")
  private String pipelineName;

  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 100, message = "commandParam长度范围最大100")
  @Schema(name = "maven 参数")
  private String commandParam;

  @Schema(name = "jenkins构建号")
  private Integer buildNum;

  @Size(groups = {IUpdateVo.class,
      IInsertVo.class}, max = 200, message = "imageName长度范围最大200")
  @Schema(name = "镜像名称")
  private String imageName;

  @Size(groups = {IUpdateVo.class, IInsertVo.class}, max = 20, message = "result长度范围最大20")
  @Schema(name = "构建结果")
  private String result;

  @Schema(name = "运行状态")
  private Integer runningFlag;

  @Schema(name = "租户")
  private Long tenantId;

  @NotNull(groups = {IUpdateVo.class}, message = "更新版本不能为空")
  @Schema(name = "更新版本")
  private Integer updateVersion;

  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @Schema(name = "build 时间")
  private Date createTime;

  @Schema(name = "创建人id")
  private Long createrId;

  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 20, message = "createrName长度范围最大20")
  @Schema(name = "创建人名")
  private String createrName;



  public void initLoginAccount(ILoginAccount loginAccount){
    this.tenantId = loginAccount.getTenantId();
    this.createrId = loginAccount.getId();
    this.createrName = loginAccount.getAccount();
  }
}



